home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-12-13 | 1.1 KB | 42 lines | [TEXT/KEEN] |
- # $CopyFiles : Copy file(s) to same folder, appending 'x' to each name.
- # Use with single specific file, or a selection of files.
- # Revised to use the copy() command - quick, and the resource
- # fork is preserved. Copies any kind of file.
- # Input from "Select input file..." or "MFS selected files" - it's
- # only the file names and locations that matter.
- # stdout contains a brief summary afterwards.
-
- BEGIN {
- CopyTheFiles();
- print ARGC-1, "files were copied, no problems."
- }
-
- function CopyTheFiles( i, outfile)
- {
- for (i = 1; i < ARGC; ++i)#note ARGV[0] is just "hAWK"
- {
- outfile = MakeNewFileName(i)
- if (!copy(ARGV[i], outfile))
- {
- print "Error, could not copy", ARGV[i]
- exit
- }
- print ARGV[i]
- print "\t\twas copied to"
- print outfile
- print ""
- }
- }
-
- function MakeNewFileName(which, z, j, outfile)
- {
- z = split(ARGV[which], names, ":");
- names[z] = names[z] "x"
- if (length(names[z]) > 31)
- names[z] = substr(names[z], 1, 30) "x" #trim last letter - not elegant...
- outfile = names[z]
- for (j = z-1; j >= 1; --j) #put full path name back together
- outfile = names[j] ":" outfile;
- return outfile
- }
-